﻿/*
 * ============ [ 废土 ] ============
 *
 * [ 维护者 ]  argoran@gmail.com
 * [  状态  ]  原型
 *
 * ============ [ 注释 ] ============
 *
 * 处理new指令的类
 *
 * ==================================
 */

using System;

using LastLandClient.Data;

using Up2Link.SegString;
using Up2Link.Util;

namespace LastLandClient.Core.CmdInterpreter
{
    public class CCmdNewAccount : ICommandInterpreter
    {
        public void ExecuteCommand(string _cmd, string _args)
        {
            if (_args != null)
            {
                String[] args = _args.Split(CConst.DELIMITER_ARGUMENT);
                if (args.Length == 2 && CData.clientConnected)
                {
                    CMessageSS newAccountMsg = new CMessageSS(CConst.CLIENT_MESSAGE_NEW_ACCOUNT, 0, CMessageSS.ENCODING_UTF32, args[0].Trim() + CConst.DELIMITER_USERACCOUNT + CMD5Hash.GetMD5Hash(args[1].Trim()));
                    CData.client.Send(newAccountMsg);
                }
                else if (args.Length != 2)
                {
                    CData.console.SendOutput("new指令接受两个参数");
                }
                else if (!CData.clientConnected)
                {
                    CData.console.SendOutput("玩家尚未连接服务器");
                }
                else
                {
                    CData.console.SendOutput("无效的指令");
                }
            }
            else
            {
                CData.console.SendOutput("无效的指令");
            }
        }
    }
}
